package cn.design;

import cn.design.realize.CardVisitor;
import cn.design.realize.CashVisitor;
import cn.design.realize.LeaderConcreteElement;
import cn.design.realize.NormalConcreteElement;
import cn.design.realize.ObjectStructure;
import cn.design.realize.Visitor;

/**
 * @author dlq
 * @description 访问者客户端具体类
 * @date 2020/10/20 10:05
 * @since 1.0
 */
public class VisitorClientDemo {
    public static void main(String[] args) {
        //发工资问题
        //分两个发放,一个是普通员工的发放,一个是领导的的发放
        //一个是现金发放,一个是银行卡发放
        //领导和普通员工可以现金发放,也可以银行卡发放

        //1. 定义员工和领导
        LeaderConcreteElement lead1 = new LeaderConcreteElement("张三-a","10000元");
        LeaderConcreteElement lead2 = new LeaderConcreteElement("李四-a","20000元");
        NormalConcreteElement normal1 = new NormalConcreteElement("赵虎-b","6000元");
        NormalConcreteElement normal2 = new NormalConcreteElement("王五-b","5000元");

        //2. 初始化对象结构
        ObjectStructure objectStructure = new ObjectStructure();
        //3. 添加元素
        objectStructure.addElement(lead1).addElement(lead2);
        objectStructure.addElement(normal1).addElement(normal2);

        //4. 定义具体访问者,发放工资方式--现金
        Visitor visitor = new CashVisitor();
        objectStructure.accept(visitor);
        System.out.println("=================");
        //5. 银行卡方式
        visitor = new CardVisitor();
        objectStructure.accept(visitor);

    }
}
